/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#define CHANNEL_NUM (8)  
#define	ADCDATA_FIFO_DEPTH				(32)
#define UPLINKFRAME_FIFO_SIZE    30
typedef struct
{
  unsigned char StartByte;
  unsigned char FrameType;
  unsigned char ECGData[24];
  unsigned char PaceFlag;
  unsigned char Checksum;
  unsigned short leadstatus;
  unsigned short overstatus;	
  unsigned char Checksum_Ana_out;  
}SDE15_UplinkFrame_ECGData_TypeDef;
typedef struct
{
  unsigned char StartByte;
  unsigned char FrameType;
  unsigned char Reserved[25];
  unsigned char Checksum;
  unsigned char StartByte_Ana_out;
  unsigned char FrameType_Ana_out;
  unsigned char data[2];
  unsigned char Checksum_Ana_out;  
}SDE15_UplinkFrame_Generic_TypeDef;
typedef enum
{
  DE15_STATE_SAMPLE = 0x00,
  DE15_STATE_NON_SAMPLE = 0x01
}EDE15_STATE_Typedef;

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
extern SPI_HandleTypeDef hspi1;
extern uint8_t g_u8_spi_rddata[27];
extern char CHANNEL;
extern int32_t gflag_uploadstatus;

extern int32_t g_i32_adcdata_FIFO[ADCDATA_FIFO_DEPTH][CHANNEL_NUM];
extern uint16_t g_i16_adcdata_FIFO_head;
extern uint16_t g_i16_adcdata_FIFO_end ;
extern int32_t i16_32to16bit_data[CHANNEL_NUM];

extern SDE15_UplinkFrame_ECGData_TypeDef g_t_UplinkFrame_ECGData;
extern SDE15_UplinkFrame_Generic_TypeDef g_arr_UplinkFrame0[UPLINKFRAME_FIFO_SIZE];
extern uint8_t g_FrameToStore_FIFO_Head;
extern uint8_t g_FrameToStore_FIFO_End;
extern EDE15_STATE_Typedef g_e_de15_state;
/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define ADC_cs_Pin GPIO_PIN_4
#define ADC_cs_GPIO_Port GPIOA
#define MCU_wdi_Pin GPIO_PIN_0
#define MCU_wdi_GPIO_Port GPIOB
#define Drdy_Pin GPIO_PIN_8
#define Drdy_GPIO_Port GPIOA
#define Drdy_EXTI_IRQn EXTI9_5_IRQn
#define ADC_start_Pin GPIO_PIN_5
#define ADC_start_GPIO_Port GPIOB
#define ADC_reset_Pin GPIO_PIN_6
#define ADC_reset_GPIO_Port GPIOB
#define ADC_pwen_Pin GPIO_PIN_7
#define ADC_pwen_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
